<?php
/**
 * 体检中心
 *
 * User: kaikaic
 * Date: 2018/10/24
 * Time: 15:59
 */

namespace app\exam\service;

use service\BasicService;
use think\Db;

class MecService extends BasicService {

    public function init() {
        $this->dataTable = ['ExamMec'];
    }

    public function listMec($type=0) {
        $records = $this->listAll(0,$type);

        $classList = array();
        for ($i=0; $i<count($records); $i++) {
            $temp = $records[$i];

            $classList[$temp['id']] = $temp['name'];
        }

        return $classList;
    }
    public function listGroupMec() {
        $records = $this->lisGrouptAll();

        $classList = array();
        for ($i=0; $i<count($records); $i++) {
            $temp = $records[$i];

            $classList[$temp['id']] = $temp['name'];
        }

        return $classList;
    }
    /**
     * 体检中心信息(可用)
     */
    public function getMec($mecID) {
        $where = array();
        $where['status'] = 1;
        $where['id'] = $mecID;

        return $this->single($mecID);
    }

    public function listAll($tableIndex=0,$type) {

            return Db::name($this->dataTable[$tableIndex])->select();

    }
    public function getSetType() {
        return Db::name('system_category')->where('pid','14')->select();
    }
    /**
     * 当前排序最大值,新纪录自动+1
     */
    public function getMaxSort($tableIndex=0) {
        return Db::name($this->dataTable[$tableIndex])->max('sort');
    }
}

